package com.example.base.net

import com.example.base.entity.*
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

interface ApiService {
    //发送验证码
    @POST(Const.SEND_CODE_URL)
    suspend fun sendCode(@Query("phone")phone:String):SendCodeEntityResult
    //验证码登录
    @POST(Const.LOGIN_CODE_URL)
    suspend fun loginCode(@Body body:RequestBody):LoginEntityResult

    @GET(Const.GET_URSER_URL)
    suspend fun getUser():GetUserEntityResult
    @POST(Const.UPDATE_PWD_URL)
    suspend fun updatePwd(@Body body: RequestBody):UpdatePwdEntityResult
    @POST(Const.LOGIN_URL)
    suspend fun login(@Body body: RequestBody):LoginEntityResult
    @GET(Const.INDEX_URL)
    suspend fun index():IndexEntityResult
    @GET(Const.INDEX_GOODS_URL)
    suspend fun indexGoods(@Path("type")type:Int,@Query("limit")limit:Int,@Query("page")page:Int):GoodsEntityResult
    @GET(Const.SEARCH_URL)
    suspend fun search(@Query("cid")cid:Int,@Query("keyword")keyword:String,@Query("limit")limit:Int,
                       @Query("news")news:Boolean,@Query("page")page:Int,
                       @Query("priceOrder")priceOrder:String,@Query("salesOrder")salesOrder:String):GoodsEntityResult
    @GET(Const.DETAIL_URL)
    suspend fun detail(@Path("id")id:Int,@Query("type")type:String):DetailEntityResult
    @POST(Const.ADD_URL)
    suspend fun addCar(@Body body: RequestBody):AddEntityResult
    @GET(Const.SEARCH_URL)
    suspend fun searchNew(@Query("keyword")keyword:String,@Query("limit")limit:Int,@Query("page")page:Int):GoodsEntityResult
    //当没有关键词搜索案例
    @GET(Const.SEARCH_URL)
    suspend fun newSearch(@Query("limit")limit:Int,@Query("page")page:Int):GoodsEntityResult
    @GET(Const.GETCAR_URL)
    suspend fun getCar(@Query("isValid")isValid:String,@Query("limit")limit:String,@Query("page")page:String):CarEntityResult
    @POST(Const.UPDATE_URL)
    suspend fun updateCar(@Query("id")id:Int,@Query("number")number:Int):UpdateEntityResult

    @POST(Const.DELETE_URL)
    suspend fun deleteCar(@Query("ids")ids:Array<Int>):UpdateEntityResult
    @GET(Const.CATEGORY_URL)
    suspend fun category():CategoryEntityResult
    @GET(Const.REPLY_URL)
    suspend fun getReply(@Path("id")id:Int,@Query("limit")limit:Int,@Query("page")page:Int,@Query("type")type:String):ReplyEntityResult
    @GET(Const.comment_url)
    suspend fun getComment():CommentEntityResult
    @POST(Const.PREORDER_URL)
    suspend fun preOrder(@Body body:PreOrderEntityParam):PreOrderEntityResult
    @GET(Const.GETPREORDER_URL)
    suspend fun getPreOrder(@Path("preOrderNo")preOrderNo:String):GetPreOrderEntityResult
    @POST(Const.CREATEORDER_URL)
    suspend fun createOrder(@Body body: CreateOrderEntityParam):CreateOrderEntityResult
    @Multipart
    @POST(Const.IMAGE_URL)
    suspend fun image(@Query("model")model:String,@Query("pid")pid:String,@Part("multipart") multipart: MultipartBody.Part):ImageEntityResult
    @GET(Const.ORDER_URL)
    suspend fun order(@Query("type")type:String,@Query("limit")limit:Int,@Query("page")page:Int):OrderEntityResult
}